/*
 * Copyright 2009 Andreas Borglin andreas.borglin@gmail.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

package borge.mobile.lib.pimp;

/**
 * This class represents an image operation.
 * It provides information on support, boundaries, presets etc.
 * An operation is typically related to either integer values
 * or predefined String values
 * Use ImageSupport to retrieve instances.
 * @author Andreas Borglin
 */
public class ImageOperation implements ImageConstants{
    
    /** Flag for operations where values are not applicable */
    public static final int VALUES_NONE = 0;
    /** Flag for operation with integer values */
    public static final int VALUES_INTEGER = 1;
    /** Flag for operation with predefined string values */
    public static final int VALUES_STRING = 2;
    /** Flag for operation with integer values and predefined string values */
    public static final int VALUES_BOTH = 3;
    
    private boolean supported = false;
    private int type = NO_VALUE;
    private int min = NO_VALUE;
    private int max = NO_VALUE;
    private int resolution = NO_VALUE;
    private int defaultValue = NO_VALUE;
    
    private String description = "Unknown";
    private String[] presets = null;
    
    private int[] conflictOps;

    protected ImageOperation(boolean sup, int type, int min, int max, int res, int def, String desc, String[] pres, int[] co) {
    
        supported = sup;
        this.type = type;
        this.min = min;
        this.max = max;
        resolution = res;
        defaultValue = def;
        description = desc;
        presets = pres;
        conflictOps = co;
    }
    
    protected int[] getConflictingOps(){
        return conflictOps;
    }
    
    /**
     * Get support information on this operation.
     * @return True if this operation is supported. False if not.
     */
    public boolean isSupported(){
        return supported;
    }
    
    /**
     * An operation is set using integer values, predefined string values or both.
     * Use this method to find out what this operation supports.
     * @return One of the predefind VALUES_XXX flags set in this class.
     */
    public int getOperationType(){
        return type;
    }
    
    /**
     * Get the minimum value that can be set for this operation.
     * For operations where it is not applicable, ImageConstants.NO_VALUE will be returned.
     * @return Minimum value, or ImageConstants.NO_VALUE.
     */
    public int getMinValue(){
        return min;
    }
    
     /**
     * Get the maximum value that can be set for this operation.
     * For operations where it is not applicable, ImageConstants.NO_VALUE will be returned.
     * @return Maximum value, or ImageConstants.NO_VALUE.
     */
    public int getMaxValue(){
        return max;
    }
    
     /**
     * Get the resolution of possible values between min and max value.
     * For operations where it is not applicable, ImageConstants.NO_VALUE will be returned.
     * @return Resolution value, or ImageConstants.NO_VALUE.
     */
    public int getResolution(){
        return resolution;
    }
    
     /**
     * Get the default integer value of this operation.
     * For operations where it is not applicable, ImageConstants.NO_VALUE will be returned.
     * @return Default integer value, or ImageConstants.NO_VALUE.
     */
    public int getDefaultValue(){
        return defaultValue;
    }
    
    /**
     * Get the description of this operation.
     * @return A description of this operation
     */
    public String getDescription(){
        return description;
    }
    
    /**
     * Get an array of supported predefined string values
     * @return A string array of values, or null if not applicable.
     */
    public String[] getSupportedModes(){
        return presets;
    }

}
